package homework;

/**
 * Created by Administrator on 2017/7/31 0031.
 */
import java.util.Scanner;

public class CapitalAmount {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入金额：");
        String amountStr = scanner.next();
        int valueInt = Integer.parseInt(amountStr);    // String --> int
        int len = amountStr.length();
        String output = "";
        char[] capitals = {'零', '壹', '贰', '叄', '肆', '伍', '陆', '柒', '捌', '玖'};
        String[] unit = {" ","拾", "佰", "仟", "万", "拾", "佰", "仟", "亿","拾亿","佰亿","仟亿"};
        for (int j = len ; j >0; j--) {
            int i = (int) (valueInt / (Math.pow(10, j-1))) % 10;
            output += capitals[i];
            if(i!=0) {
                output += unit[j - 1];
            }
        }
        System.out.println("大写为：");
        System.out.println(output);
    }
}

